/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.leospa.main;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JRootPane;

import com.leospa.bean.Command_0;
import com.leospa.properties.ConfigPropertiesFile;
import com.leospa.properties.ContentPropertiesFile;

/**
 *
 * @author ADMIN
 */
public class TimerWithoutAmmount {

    /**
     * Creates new form ConfirmationScreen
     */
	
	int MIN_TIME = 0;
	int MAX_TIME = 0;
	int STEP_TME = 0;
	int time =0;
	int count = 0;
	MainScreen mainScreen;
	javax.swing.GroupLayout layout;

	public TimerWithoutAmmount(MainScreen mainScreen, javax.swing.GroupLayout layout) {
		this.layout = layout;
		this.mainScreen = mainScreen;
//    	try {
//			URL imgURL = new File( "./images/backgrond.png" ).toURI().toURL();
//			setContentPane(new JLabel(new ImageIcon(imgURL)));
//		} catch (MalformedURLException e) {
//			// TODO Auto-generated catch block
//			if(ConfigPropertiesFile.DEBUG_MODE_ON == true){e.printStackTrace();}
//		}
        initComponents();
        Command_0 command_0 = Util.getUtilInstance().getCommand_0();
        MIN_TIME = Integer.parseInt(command_0.getMINTIME());
        time = MIN_TIME;
        int min = time/60;
        int sec = time%60;
        String minSt =""+min;
		 if(min <10){
			 minSt="0"+min;
		 }
		 String secSt = ""+sec;
		 if(sec <10){
			 secSt ="0"+sec;
		 }
	    jLabel1.setText(""+minSt+":"+secSt+" Min");
        MAX_TIME = Integer.parseInt(command_0.getMAXTIME());
        STEP_TME = Integer.parseInt(command_0.getSTEPTIME());
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();


        jPanel1.setMaximumSize(new java.awt.Dimension(800, 1280));
        jPanel1.setMinimumSize(new java.awt.Dimension(800, 1280));
        jPanel1.setOpaque(false);
        jPanel1.setPreferredSize(new java.awt.Dimension(800, 1280));

        jPanel2.setBackground(new java.awt.Color(152, 63, 200));
        jPanel2.setPreferredSize(new java.awt.Dimension(786, 768));

        jLabel2.setBackground(new java.awt.Color(105, 135, 182));
        jLabel2.setFont(new java.awt.Font("SansSerif", 1, 48)); // NOI18N
        jLabel2.setForeground(new java.awt.Color(255, 255, 255));
        jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel2.setText(ContentPropertiesFile.Please_Select_Time);
        jLabel2.setOpaque(true);
        
        jLabel1.setFont(new java.awt.Font("SansSerif", 0, 45)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(255, 255, 255));
       // jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);

        try {
			URL imgURL = new File( "./images/7.png" ).toURI().toURL();
			jButton1.setIcon(new javax.swing.ImageIcon(imgURL)); // NOI18N
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			if(ConfigPropertiesFile.DEBUG_MODE_ON == true){e.printStackTrace();}
		}
        jButton1.setContentAreaFilled(false);
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
            	if(time <= MAX_TIME && time >MIN_TIME){
            		time = time - STEP_TME;
            		if(time >= MIN_TIME){
	            		time = time - STEP_TME;
	            		count --;
	            		 int min = time/60;
	            		 String minSt =""+min;
	            		 if(min <10){
	            			 minSt="0"+min;
	            		 }
	            		 int sec = time%60;
	            		 String secSt = ""+sec;
	            		 if(sec <10){
	            			 secSt ="0"+sec;
	            		 }
	            	     jLabel1.setText(""+minSt+":"+secSt+" Min");
            		} else {
            			time = time + STEP_TME;
            		}
            	}
            }
        });
        try {
			URL imgURL = new File( "./images/9.png" ).toURI().toURL();
			jButton2.setIcon(new javax.swing.ImageIcon(imgURL)); // NOI18N
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			if(ConfigPropertiesFile.DEBUG_MODE_ON == true){e.printStackTrace();}
		}
        jButton2.setContentAreaFilled(false);
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
            	jPanel1.setVisible(false);
            	ConfirmationAfterTimeSelection confirmationAfterTimeSelection = new ConfirmationAfterTimeSelection(time,0,count,mainScreen,layout);
            	confirmationAfterTimeSelection.setLayout();
            }
        });

        try {
			URL imgURL = new File( "./images/8.png" ).toURI().toURL();
			jButton3.setIcon(new javax.swing.ImageIcon(imgURL)); // NOI18N
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			if(ConfigPropertiesFile.DEBUG_MODE_ON == true){e.printStackTrace();}
		}
        jButton3.setContentAreaFilled(false);
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
            	jPanel1.setVisible(false);
            	GuthabenInfoScreen guthabenInfoScreen = new GuthabenInfoScreen(mainScreen,layout);
            	guthabenInfoScreen.setLayout();
            }
        });

        jButton4.setBackground(null);
        try {
			URL imgURL = new File( "./images/6.png" ).toURI().toURL();
			jButton4.setIcon(new javax.swing.ImageIcon(imgURL)); // NOI18N
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			if(ConfigPropertiesFile.DEBUG_MODE_ON == true){e.printStackTrace();}
		}
        jButton4.setContentAreaFilled(false);
        jButton4.setOpaque(false);
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
            	if(time >= MIN_TIME && time < MAX_TIME){
            		time = time + STEP_TME;
            		if(time <=MAX_TIME){
	            		time = time + STEP_TME;
	            		count++;
	            		 int min = time/60;
	            	        int sec = time%60;
	            	        String minSt =""+min;
	            			 if(min <10){
	            				 minSt="0"+min;
	            			 }
	            			 String secSt = ""+sec;
	            			 if(sec <10){
	            				 secSt ="0"+sec;
	            			 }
	            		  jLabel1.setText(""+minSt+":"+secSt+" Min");
            		} else {
            			time = time - STEP_TME;
            		}
            	}
            }
        });

       
        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap(63, Short.MAX_VALUE)
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 312, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(59, 59, 59))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(96, 96, 96)
                .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(60, 60, 60)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jButton2)
                            .addComponent(jButton4)))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(86, 86, 86)
                        .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(31, 31, 31)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jButton3)
                    .addComponent(jButton1))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        //-----------------------------
        
        
        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(0, 0, 0)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(150, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(0, 0, 0)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(730, Short.MAX_VALUE))
        );


       
    }// </editor-fold>    
    
    public void setLayout(){
    	 layout = new javax.swing.GroupLayout(mainScreen.getContentPane());
    	 mainScreen.getContentPane().setLayout(layout);
         layout.setHorizontalGroup(
             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                 .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                 .addGap(135, 135, 135))
         );
         layout.setVerticalGroup(
             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                 .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                 .addGap(94, 94, 94))
         );

         mainScreen.pack();
    }

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
    }                                        

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(TimerWithoutAmmount.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(TimerWithoutAmmount.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(TimerWithoutAmmount.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(TimerWithoutAmmount.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>
        //</editor-fold>
        //</editor-fold>
        //</editor-fold>
//        new TimerWithoutAmmount().setVisible(true);
        /* Create and display the form */
//        java.awt.EventQueue.invokeLater(new Runnable() {
//            public void run() {
//               
//            }
//        });
    }

    // Variables declaration - do not modify                     
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    // End of variables declaration                   
}
